<template>
    <div id='videoElement'></div>
</template>

<script>
let DHPlayerObj = null
import DHPlayer from '../../utils/player/DHPlayer';
import { getCameraPlayUrl } from '@/api/index.js'
export default {
    methods: {
        startPlayer() {
            getCameraPlayUrl({"channelCode": "1000004$1$0$0"}).then(res => {
                if (!res.data) return;
                if (!DHPlayerObj) {
                    console.log("不能播放，请先初始化！！！！！");
                    return;
                }
                DHPlayerObj.startPlayer(res.data.url);
            })
        }
        
    },
    created() {
        DHPlayerObj = new DHPlayer("videoElement")
        this.startPlayer()
    },
    destroyed() {
        DHPlayerObj?.destroy()
    }
}
</script>

<style scoped>
#videoElement {
    width: 1000px;
    height: 500px;
}
</style>